<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p><input type="text" name="" id="uname"></p>
    <p><input type="text" name="" id="age"></p>
    <p><input type="button" value="提交" id='btn'></p> 
    <script>
        var btn=document.getElementById('btn')
        var uname=document.getElementById('uname')
        var age=document.getElementById('age')
        btn.onclick=function(){
            var xhr=new XMLHttpRequest()
            var namevalue=uname.value
            var agevalue=age.value
           
            // alert(namevalue)
            // alert(age)
            var params='username='+namevalue+'&age='+agevalue;
            xhr.open('get','http://localhost:3000/get?'+params)
            xhr.send()
            xhr.onload=function(){
                console.log(xhr.responseText)
            }
        }
    </script>  
</body>
</html>